package com.maxima.attendance.actions;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

public class SessionManager {
	public static final String USER_LOGIN = "userLoggedIn";
	public static final String ADMIN_LOGIN = "adminLoggedIn";
	public static final String ACTIVE_LOGIN = "activeLogin";
	public static final String ALL_EMPLOYEE_LIST = "allEmployeeList";
	public static final String WORK_FROM_HOME_EMPLOYEE_LIST = "workFromHomeEmployeeList";
	public static final String CURRENT_EMPLOYEE_LIST = "currentEmployeeList";
	public static final String WORK_FROM_HOME_DATE = "workFromHomeDate";
	public static final String SELECTED_PROFILE = "profile";
	public static final String PROJECT_LIST = "projectList";
	public static final String SELECTED_PROJECT = "selectedProject";
	public static final String SELECTED_USER = "selectedUser";
	public static final String HOLIDAY_LIST = "holidayList";
	public static final String SELECTED_HOLIDAY = "selectedHoliday";
	public static final String SELECTED_DATE = "selectedDate";

	public static boolean validateUserSession() {
		Object obj = ServletActionContext.getRequest().getSession().getAttribute(USER_LOGIN);
		if (obj != null) {
			return (Boolean) obj;
		} else {
			return false;
		}
	}

	public static boolean validateAdminSession() {
		Object obj = ServletActionContext.getRequest().getSession().getAttribute(ADMIN_LOGIN);
		if (obj != null) {
			return (Boolean) obj;
		} else {
			return false;
		}
	}

	public static void clearSession() {
		HttpSession session = ServletActionContext.getRequest().getSession(false);
		if (session != null) {
			session.invalidate();
		}
	}

	public static boolean checkSession() {
		HttpSession session = ServletActionContext.getRequest().getSession(false);
		if (session != null) {
			return true;
		}
		return false;
	}
}
